home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual Foxpro 6.0 (Ent. Edition) / Vf6ent Extractor.EXE / API / SAMPLES / MODIFER.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-26  |  1.9 KB  |  96 lines

  1. /*
  2. **
  3. *
  4. * MODIFIER.C - Sample API routine.
  5. *
  6. * Copyright (c) 1989-1993 Microsoft Corporation as an unpublished
  7. * licensed proprietary work.  All rights reserved.
  8. *
  9. * Description:
  10. *        This library establishes an Event Handler
  11. *         which will display which Key Code should be
  12. *        used when a key is pressed.  This is
  13. *        dependent upon the modifier keys used during
  14. *        the key press.
  15. *
  16. **
  17.  */
  18.  
  19.  
  20.  
  21. #include <pro_ext.h>
  22.  
  23. int         eventid;
  24.  
  25.  
  26. //
  27. // This routine is registered as an event handler.
  28. // But only cares about keyDownEvents which it then
  29. // passes on to FoxPro.
  30. //
  31.  
  32. FAR EventHandler(WHandle theWindow, EventRec FAR *ev)
  33. {
  34.  
  35.  
  36.  
  37.     switch(ev->what)
  38.     {
  39.  
  40.     case keyDownEvent:
  41.             if (ev->modifiers & shiftCodeMask)   /* A modifier was pressed. */
  42.             {
  43.                 if (ev->modifiers & altKey)      /* Alt Key */
  44.  
  45.                     _PutStr("Alt Key Code should be used.\n");
  46.  
  47.                 else
  48.                     if (ev->modifiers & ctrlKey) /* Ctrl Key */
  49.  
  50.                         _PutStr("Ctrl Key Code should be used.\n");
  51.  
  52.                     else
  53.                         if (ev->modifiers & shiftKey)    /* Shift Key */
  54.  
  55.                             _PutStr("Shift Key Code should be used.\n");
  56.             }
  57.             else                                 /* Normal Key press */
  58.                 _PutStr("Regular Key Code should be used.\n");
  59.  
  60.             return NO;
  61.             break;
  62.  
  63.  
  64.  
  65.         default:
  66.         return NO;
  67.     }
  68.     return YES;
  69. }
  70.  
  71. FAR Modifier()
  72. {
  73.  
  74.     eventid = _ActivateHandler(EventHandler);
  75.  
  76. }
  77.  
  78.  
  79.  
  80. FAR ModifierExit()
  81. {
  82.  
  83.     _DeActivateHandler(eventid);
  84.  
  85. }
  86.  
  87.  
  88. FoxInfo myFoxInfo[] = {
  89.     {"MODIFIER", (FPFI) Modifier, CALLONLOAD, ""},
  90.     {"MODIFIEREXIT", (FPFI) ModifierExit, CALLONUNLOAD, ""}
  91. };
  92.  
  93. FoxTable _FoxTable = {
  94.     (FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
  95. };
  96.